<%--
  Created by IntelliJ IDEA.
  User: Lenovo
  Date: 2021/4/25
  Time: 20:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>首页</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="/aistar/plugins/layui-v2.6.5/layui/css/layui.css">
    <link rel="stylesheet" href="/aistar/plugins/bootstrap/css/bootstrap.min.css">

</head>
<body>
    <%@include file="../nav/nav.jsp"%>

    <div class="container-fluid hidden-xs" style="margin-top: -20px; background-image: url('/aistar/imgs/mi.webp'); background-size: contain">
        <div class="row" style="height: 380px;background: rgba(1,0,0,0.4);">
            <h2 style="text-align: center;color: white" >
                iMac
                <p>由内而外，焕然一新。超乎想象的纤薄设计，24 英寸 4.5K 视网膜显示屏</p>
                <p>以及 Mac 中出类拔萃的扬声器、麦克风和摄像头</p>
                <p>种种精彩，由 M1 芯片强势驱动。</p>
            </h2>
        </div>
    </div>
    <div class="container-fluid" style="margin-top: 20px">
        <div class="row">
            <c:forEach items="${pageInfo.list}" var="p">
                <div class="col-md-3">
                    <div class="thumbnail">
                        <img src="http://localhost:80/product/${p.productImg}"
                             alt="通用的占位符缩略图">
                        <div class="caption">
                            <h3>${p.name}</h3>
                            <p style="color:red">优惠价：${p.price}<span class="text-primary">库存:${p.store}</span></p>
                            <p class="text-info">销量:${p.sales+10000}</p>
                            <p>
                                ${p.remark}
                            </p>
                        </div>
                    </div>
                </div>
            </c:forEach>

        </div>
    </div>

    <div class="container" style="text-align: center">
        <ul class="pagination">
            <li><a href="javascript:nextPage(${pageInfo.pageNum-1})">&laquo;</a></li>

            <c:set var="start" value="${pageInfo.pageNum}"></c:set>

            <c:if test="${pageInfo.pageNum+2<=pageInfo.pages}">
                <c:set var="end" value="${pageInfo.pageNum+2}"></c:set>
            </c:if>

            <c:if test="${pageInfo.pageNum+2>pageInfo.pages}">
                <c:set var="start" value="${pageInfo.pages-2}"></c:set>
                <c:set var="end" value="${pageInfo.pageNum+2}"></c:set>
            </c:if>



            <c:forEach begin="${start}" end="${end}" var="n">
                <c:if test="${pageInfo.pageNum==n}">
                    <li class="active"><a href="javascript:nextPage(${n})">${n}</a></li>
                </c:if>
                <c:if test="${pageInfo.pageNum==n}">
                    <li><a href="javascript:nextPage(${n})">${n}</a></li>
                </c:if>

            </c:forEach>
            <li><a href="javascript:nextPage(${pageInfo.pageNum+1})">&raquo;</a></li>
            <li><a>当前页${pageInfo.pageNum}/${pageInfo.pages}</a></li>
        </ul>
    </div>



    <script src="/aistar/plugins/jquery/jquery.min.js"></script>
    <script src="/aistar/plugins/bootstrap/js/bootstrap.js"></script>

    <script>
        function nextPage(pageNow) {
            window.location="/aistar/product/index?pageNow="+pageNow;

        }
    </script>
</body>
</html>
